// pages/shoudanyoulilingqu/shoudanyoulilingqu.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    USER_ASSETS_IDCARD: '',
    USER_ASSETS_NAME: '',
    login_id: '',
    flag: true, //设置节流
    VALID:'',
    USER_ASSETS_ID:'',
    login_idkashi:"",
  },



  // 支付宝领取

  tjok() {
    if (this.data.flag) {

      this.data.flag = false
      this.setData({
        openid: app.globalData.openid,
        jiami: app.globalData.jiami,
        OPEN_ID: app.globalData.openid,
        session_key: app.globalData.session_key,
      })

      if (this.data.login_id == '') {
        wx.showToast({
          title: '请输入手机号！',
          icon: 'none',
          duration: 1500
        })
      }else if (this.data.login_id != this.data.login_idkashi) {
        
        wx.showToast({
          title: '两次输入账号不一致！',
          icon: 'none',
          duration: 1500
        })

      } else{

        wx.request({
          url: app.globalData.interface+'/squareDance/API_5323_sendpostBigBroadcastALiPay',
          method: 'POST',
          data: {
            USER_ASSETS_ID:this.data.USER_ASSETS_ID,
            login_id: this.data.login_id,
            USER_ASSETS_IDCARD: this.data.USER_ASSETS_IDCARD,
            openid: this.data.openid,
            USER_COUPON_ID:this.data.USER_COUPON_ID,


            OPEN_ID: this.data.openid, //用户OPEN_ID
            session_key:this.data.session_key,
            OPEN_UUID:this.data.jiami
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          success: res => {
            console.log(res);
            wx.showModal({
              title: '温馨提示',
              content: res.data.data,
              success: function (res) {
                if (res.confirm) {//这里是点击了确定以后
                  console.log('用户点击确定')
                  wx.navigateBack({
                    delta: 2,
                  })
                } else {//这里是点击了取消以后
                  console.log('用户点击取消')
                  wx.navigateBack({
                    delta: 2,
                  })
                }
              }
            })
          }
        })
      
      }

      
      setTimeout(() => {
        this.data.flag = true
      }, 4500)
    }
  },

  back() {
    wx.navigateBack({
      delta: 1,
    })
  },



  quno() {
    wx.navigateBack({
      delta: 1,
    })
  },



  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(e) {
    console.log(e)
    var zhunsj = JSON.parse(e.data)
    console.log(zhunsj);
    // console.log(zhunsj.data.USER_ASSETS_IDCARD);
    this.setData({
      USER_ASSETS_IDCARD: zhunsj.USER_COUPON_PHONE,
      USER_ASSETS_NAME: zhunsj.USER_ASSETS_NAME,
      VALID:zhunsj.VALID,
      USER_ASSETS_ID:zhunsj.USER_ASSETS_ID,
      USER_COUPON_ID:zhunsj.USER_COUPON_ID,
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})